
//获取数据持久化
let user = localStorage.getItem('user')
let userinfo = {username: '',isLogin: false,token: ''}
if(user){
    userinfo = JSON.parse(user)
}

export default {
    namespaced: true,//开启命名空间
    state: {
        userinfo: {
            username: '',
            isLogin: false,
            token: ''
        }
    },
    mutations: {
        //设置用户信息
        setUser(state, payload) {
            state.userinfo = payload
        },
        //清空用户信息
        deleteUser(state) {
            state.userinfo = {
                username: '',
                isLogin: false,
                token: ''
            }
        }
    },
    actions: {

    }
}

